#include <iostream>
#include <vector>
#include <assert.h>
using namespace std;
namespace hql
{
	class Date
	{
		friend ostream& operator<<(ostream& out, const Date& date);
	public:
		bool operator<(const Date& d) const
		{
			return (_year < d._year) 
				|| (_year == d._year && _month < d._month) 
				|| (_year == d._year && _month == d._month && _day < d._day);
		}
		bool operator>(const Date& d) const
		{
			return (_year > d._year)
				|| (_year == d._year && _month > d._month)
				|| (_year == d._year && _month == d._month && _day > d._day);
		}
		
		Date(int year = 1990, int month = 1, int day =2 )
			:_year(year)
			, _month(month)
			, _day(day) {};

		
	private:
		int _year;
		int _month;
		int _day;
	};

	ostream& operator<<(ostream& out, const Date& date)
	{
		out << date._year << "-" << date._month << "-" << date._day;
		return out;
	}

	template<class T>
	struct Less
	{
		bool operator()(const T& a, const T& b) const
		{
			return a < b;
		}
	};
	template<class T>
	struct Greater
	{
		bool operator()(const T& a, const T& b) const
		{
			return a > b;
		}
	};
	struct LessPDate
	{
		bool operator()(const Date* d1, const Date* d2) const
		{
			return *d1 < *d2;
		}
	};

	struct GreaterPDate
	{
		bool operator()(const Date* d1, const Date* d2) const
		{
			return *d1 > *d2;
		}
	};
	template<class T, class Container = vector<T>, class Compare = Less<T>>
	class priority_queue
	{
	public:
		
		priority_queue(){}
		template<class InputIterator>
		priority_queue(InputIterator first, InputIterator last)
			:_con(first, last)
		{
			for (int i = (_con.size() - 1 - 1) / 2; i >= 0; i--) {
				adjust_down(i);
			}
		}
		
	private:
		void adjust_up(size_t child)
		{
			Compare com;
			size_t parent = (child - 1) / 2;
			while (child > 0) {
				//if (_con[child] > _con[parent]) 
				if (com(_con[parent],_con[child]))
				{
					swap(_con[child], _con[parent]);
					child = parent;
					parent = (child - 1) / 2;
				}
				else 
				{
					break;
				}
			}
		}
		void adjust_down(size_t parent)
		{
			Compare com;
			size_t child = parent * 2 + 1;
			while (child < _con.size())
			{
				if (child + 1 < _con.size() && com(_con[child] , _con[child + 1])) {
					child++;
				}
				//if (_con[child] > _con[parent]) 
				if(com(_con[parent], _con[child]))
				{
					swap(_con[child], _con[parent]);
					parent = child;
					child = parent * 2 + 1;	
				}
				else 
				{
					break;
				}
			}
		}
	public:
		void push(const T& x)
		{
			_con.push_back(x);
			adjust_up(_con.size()-1);
		}
		void pop()
		{
			assert(!_con.empty());
			swap(_con[0], _con[_con.size() - 1]);
			_con.pop_back();
			adjust_down(0);
		}
		const T& top()
		{
			return _con[0];
		}
		size_t size()
		{
			return _con.size();
		}
		bool empty()
		{
			return _con.empty();
		}
	private:
		Container _con;

	};
}